﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common
{
   public class LanguageSetting
    {
       /// <summary>
       /// 获取当前语言类型
       /// </summary>
       /// <returns></returns>
       public static int GetCurrentLanguageId()
       {
           string filePath = System.Windows.Forms.Application.StartupPath + @"\ProjectConfig.ini";//配置文件路径
           string language = new Common.INIFileHelper(filePath).IniReadValue("工程文件", "语言");
           string languageId = new Common.INIFileHelper(filePath).IniReadValue("工程文件", "语言ID");
           int id = 0;
           if (languageId != string.Empty)
           {
               id = Convert.ToInt32(languageId);
               System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language);
           }
           else
           {
               id = 1;
               new Common.INIFileHelper(filePath).IniWriteValue("工程文件", "语言", "zh-CN");
               new Common.INIFileHelper(filePath).IniWriteValue("工程文件", "语言ID", "1");
           }
           return id;
       }
    }
}
